package Ajedrez;

class Caballo extends Pieza{

    protected int iniX, iniY, finX, finY;

    public Caballo() {
    }

    public Caballo( int iniX, int iniY, int finX, int finY) {	//javax.swing.JOptionPane.showInputDialog(" " + corrept);
        this.iniX = iniX;
        this.iniY = iniY;
        this.finX = finX;
        this.finY = finY;
        int pos[][] = {{2, 1},
            {2, -1},
            {1, 2},
            {1, -2},
            {-2, 1},
            {-2, -1},
            {-1, 2},
            {-1, -2},};
        int i, f;
        int r = -1;
        for (int x = 0; x < 8; x++) {
            i = this.iniX + pos[x][0];
            f = this.iniY + pos[x][1];
            if ((i > -1) && (i < 8) && (f > -1) && (f < 8)) {
                if ((i == this.finX) && (f == this.finY)) {
                    corrept = true;

                    r = 1;
                }
            }
        }

        if (r == -1) {
            corrept = false;

        }

    }
}
